# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=widelands
pkgver=1.1
pkgrel=7
pkgdesc="realtime strategy game with emphasis on economy and transport"
url="https://widelands.org"
arch="all !s390x" # nobody will use s390x to place widelands
license="GPL-2.0-or-later"
depends="lua python3"
makedepends="
	asio-dev
	boost-dev
	cmake
	curl-dev
	dbus-dev
	doxygen
	freeglut-dev
	gettext-dev
	glew-dev
	graphviz
	libintl
	libpng-dev
	samurai
	sdl2-dev
	sdl2_image-dev
	sdl2_mixer-dev
	sdl2_net-dev
	sdl2_ttf-dev
	zlib-dev
"
source="https://github.com/widelands/widelands/archive/v$pkgver/widelands-v$pkgver.tar.gz
	0001-link-libintl.patch
	gcc12-no-werror.patch
	sdl-use-x11.patch
	fix-cstdint.patch
	"
subpackages="$pkgname-doc"

build() {
	cmake -B build -G Ninja \
		-Wno-dev \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DWL_INSTALL_BASEDIR=/usr \
		-DWL_INSTALL_DATADIR=/usr/share/widelands
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	mv "$pkgdir"/usr/games "$pkgdir"/usr/bin

	mkdir -p "$pkgdir"/usr/share/doc/"$pkgname"
	for _file in VERSION ChangeLog CREDITS; do
		mv "$pkgdir/usr/$_file" "$pkgdir"/usr/share/doc/"$pkgname"
	done

	mkdir -p "$pkgdir"/usr/share/licenses/$pkgname
	mv "$pkgdir"/usr/COPYING "$pkgdir"/usr/share/licenses/"$pkgname"
}

sha512sums="
29dbeae0940468c8aad6f0fa610c8467bdb6ecf2ba5fe9175683b7cdaab5f977fa86beb71de29057c829e9738568d15e10bc22fa7fc9e58132151a1a02d72d9d  widelands-v1.1.tar.gz
645bae9804dab9a372176b070797c51a6720cb7372e786b3eab868fada63c7b7ddf6815b687886267d13cfe90c0ecf7516e44b3f5c921a0024c1a30e0fb87344  0001-link-libintl.patch
6c9b93ca12b9bdb13acd49027d672a46fac0c30511167d8ae3adc2ce0d4a2c6457fde22bc4bcf9d093542a306c829afabaa4066d679c95eb9441187789ed3051  gcc12-no-werror.patch
94a69e35f1bb9a83cca26ac96ca100fccad4b8ebbb7c2db1727591b03e73e82ecec940c6dd42fa9d6369bbee2b4b238df4eb879ab084e92e0642b89a37dff2e3  sdl-use-x11.patch
279634404666556d1aaf8e9f5e1c6c2962d8537fbfdfdb9588535f10fd963247b05db94fb0867ec0ae9218ea0d58dd9ebc2f2a5d4d4df4233a095e6c80dec3a1  fix-cstdint.patch
"
